home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
dns
/
update.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
5KB
|
155 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import dns.message as dns
import dns.name as dns
import dns.opcode as dns
import dns.rdata as dns
import dns.rdataclass as dns
import dns.rdataset as dns
class Update(dns.message.Message):
def __init__(self, zone, rdclass = dns.rdataclass.IN, keyring = None, keyname = None):
super(Update, self).__init__()
self.flags |= dns.opcode.to_flags(dns.opcode.UPDATE)
if isinstance(zone, (str, unicode)):
zone = dns.name.from_text(zone)
self.origin = zone
if isinstance(rdclass, str):
rdclass = dns.rdataclass.from_text(rdclass)
self.zone_rdclass = rdclass
self.find_rrset(self.question, self.origin, rdclass, dns.rdatatype.SOA, create = True, force_unique = True)
if keyring is not None:
self.use_tsig(keyring, keyname)
def _add_rr(self, name, ttl, rd, deleting = None, section = None):
if section is None:
section = self.authority
covers = rd.covers()
rrset = self.find_rrset(section, name, self.zone_rdclass, rd.rdtype, covers, deleting, True, True)
rrset.add(rd, ttl)
def _add(self, replace, section, name, *args):
if isinstance(name, (str, unicode)):
name = dns.name.from_text(name, None)
if isinstance(args[0], dns.rdataset.Rdataset):
for rds in args:
if replace:
self.delete(name, rds.rdtype)
for rd in rds:
self._add_rr(name, rds.ttl, rd, section = section)
else:
args = list(args)
ttl = int(args.pop(0))
if isinstance(args[0], dns.rdata.Rdata):
if replace:
self.delete(name, args[0].rdtype)
for rd in args:
self._add_rr(name, ttl, rd, section = section)
else:
rdtype = args.pop(0)
if isinstance(rdtype, str):
rdtype = dns.rdatatype.from_text(rdtype)
if replace:
self.delete(name, rdtype)
for s in args:
rd = dns.rdata.from_text(self.zone_rdclass, rdtype, s, self.origin)
self._add_rr(name, ttl, rd, section = section)
def add(self, name, *args):
self._add(False, self.authority, name, *args)
def delete(self, name, *args):
if isinstance(name, (str, unicode)):
name = dns.name.from_text(name, None)
if len(args) == 0:
rrset = self.find_rrset(self.authority, name, dns.rdataclass.ANY, dns.rdatatype.ANY, dns.rdatatype.NONE, dns.rdatatype.ANY, True, True)
elif isinstance(args[0], dns.rdataset.Rdataset):
for rds in args:
for rd in rds:
self._add_rr(name, 0, rd, dns.rdataclass.NONE)
else:
args = list(args)
if isinstance(args[0], dns.rdata.Rdata):
for rd in args:
self._add_rr(name, 0, rd, dns.rdataclass.NONE)
else:
rdtype = args.pop(0)
if isinstance(rdtype, str):
rdtype = dns.rdatatype.from_text(rdtype)
if len(args) == 0:
rrset = self.find_rrset(self.authority, name, self.zone_rdclass, rdtype, dns.rdatatype.NONE, dns.rdataclass.ANY, True, True)
else:
for s in args:
rd = dns.rdata.from_text(self.zone_rdclass, rdtype, s, self.origin)
self._add_rr(name, 0, rd, dns.rdataclass.NONE)
def replace(self, name, *args):
self._add(True, self.authority, name, *args)
def present(self, name, *args):
if isinstance(name, (str, unicode)):
name = dns.name.from_text(name, None)
if len(args) == 0:
rrset = self.find_rrset(self.answer, name, dns.rdataclass.ANY, dns.rdatatype.ANY, dns.rdatatype.NONE, None, True, True)
elif isinstance(args[0], dns.rdataset.Rdataset) and isinstance(args[0], dns.rdata.Rdata) or len(args) > 1:
if len(args) > 1:
args = list(args)
args.insert(0, 0)
self._add(False, self.answer, name, *args)
else:
rdtype = args[0]
if isinstance(rdtype, str):
rdtype = dns.rdatatype.from_text(rdtype)
rrset = self.find_rrset(self.answer, name, dns.rdataclass.ANY, rdtype, dns.rdatatype.NONE, None, True, True)
def absent(self, name, rdtype = None):
if isinstance(name, (str, unicode)):
name = dns.name.from_text(name, None)
if rdtype is None:
rrset = self.find_rrset(self.answer, name, dns.rdataclass.NONE, dns.rdatatype.ANY, dns.rdatatype.NONE, None, True, True)
elif isinstance(rdtype, str):
rdtype = dns.rdatatype.from_text(rdtype)
rrset = self.find_rrset(self.answer, name, dns.rdataclass.NONE, rdtype, dns.rdatatype.NONE, None, True, True)
def to_wire(self, origin = None, max_size = 65535):
if origin is None:
origin = self.origin
return super(Update, self).to_wire(origin, max_size)